Skip to content

Migrate to Alpine Linux with 57.9% image size reduction#8

Merged
jserv merged 2 commits into
devfrom
ci-tweak
Nov 6, 2025
Merged

Migrate to Alpine Linux with 57.9% image size reduction#8
jserv merged 2 commits into
devfrom
ci-tweak

Conversation

@jserv

@jserv jserv commented Nov 6, 2025

Copy link
Copy Markdown

Migrated Docker base from Ubuntu (eclipse-temurin:11-jre-noble) to Alpine Linux 3.22, achieving 57.9% image size reduction (1.305GB → 549.8MB) while maintaining full functionality.

Infrastructure

  • Base image: eclipse-temurin:11-jre-noblealpine:3.22
  • Multi-architecture: Added support for linux/amd64 and linux/arm64 via BuildKit
  • Multi-stage build: Optimized 3-stage build (base → intermediate-builder → final)

Size Optimization

  • Python cleanup: Removed __pycache__, *.pyc, *.pyo files
  • Babel locales: 31.4MB → 640KB (kept only en_* and root.dat)
  • Test directories: Removed tests/ and testing/ from site-packages
  • Build tools: Removed pip/setuptools from final image
  • Layer optimization: Moved curl to build-only stage, used --chown on COPY

Multi-Architecture Support

  • amd64: Official coursier musl static build (v2.1.24)
  • arm64: VirtusLab coursier glibc build (v2.1.24) with gcompat layer
  • Conditional glibc: ARM64 requires glibc for coursier compatibility

Build Improvements

  • Virtual build dependencies pattern (gcc, g++, musl-dev cleaned after use)
  • Enhanced .dockerignore to exclude dev artifacts
  • Environment variable for coursier version (COURSIER_VERSION=2.1.24)

Results

Metric Before After Improvement
Image size 1.305GB 549.8MB -755.2MB (57.9%)

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant